package com.itheima.service.store.impl;

import com.github.pagehelper.PageInfo;
import com.itheima.dao.store.TravellerDao;
import com.itheima.domain.store.Traveller;
import com.itheima.factory.MapperFactory;
import com.itheima.service.store.TravellerService;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class TravellerServiceImpl implements TravellerService {
    @Override
    public List<Traveller> findByOrderId(String orderId) {

        SqlSession sqlSession = null;

        //try {
        sqlSession =  MapperFactory.getSqlSession();
        TravellerDao mapper = MapperFactory.getMapper(sqlSession, TravellerDao.class);
        List<Traveller> all = mapper.findByOrderId(orderId);



//        } catch (Exception e) {
//            System.out.println("回滚了");
//            TransactionUtil.rollback(sqlSession);
//        } finally {
//            TransactionUtil.close(sqlSession);
//        }
        return all;
    }

    @Override
    public List<Traveller> findAll() {
        SqlSession sqlSession = null;
        List<Traveller> list= null;

        //try {
            sqlSession =  MapperFactory.getSqlSession();
            TravellerDao mapper = MapperFactory.getMapper(sqlSession, TravellerDao.class);
            list = mapper.findAll();

//        } catch (Exception e) {
//            System.out.println("回滚了");
//            TransactionUtil.rollback(sqlSession);
//        } finally {
//            TransactionUtil.close(sqlSession);
//        }
        return list;
    }


    @Override
    public Traveller findById(String id) {
        return null;
    }

    @Override
    public void addTraveller(Traveller traveller) {

    }

    @Override
    public void deleteTraveller(String id) {

    }

    @Override
    public void updateTraveller(Traveller traveller) {

    }

    @Override
    public PageInfo findByPage(int currentPage, int pageSize) {
        return null;
    }
}
